using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Windows.Forms;
using THSERP.BusinessEntities;
using THSLib;

namespace THSERP.BaseProvider
{
    public class A1CompanyConfigUtility
    {
        static Dictionary<String, String> CompanyConfig = new Dictionary<string, string>();

        #region constant for A1CompanyConfig
        public const string Dummy = "All";
        public static System.Windows.Forms.FormWindowState ScreenState;
        public static bool BoneModusEK;
        #endregion     

 
        static public void CompanyConfigInit()
        {
            A1CompanyConfigsController objCompanyConfigsController = new A1CompanyConfigsController();
            DataSet dsCompanyConfigs = objCompanyConfigsController.GetAllObjects();
            A1CompanyConfigUtility.CompanyConfig.Clear();
            foreach (DataRow row in dsCompanyConfigs.Tables[0].Rows)
            {
                A1CompanyConfigUtility.CompanyConfig.Add(row["A1CompanyConfigKey"].ToString(), row["A1CompanyConfigValue"].ToString());
            }

            string StrConfigValue = String.Empty;
            #region ScreenMaximize
            StrConfigValue = A1CompanyConfigUtility.CompanyConfigFind("ScreenMaximize", StrConfigValue);
            if (StrConfigValue == string.Empty)
                MessageBox.Show("#Message: ScreenMaximize/true - Please config company!");

            StrConfigValue = StrConfigValue.ToUpper();
            if (StrConfigValue.ToString() == "TRUE")
                A1CompanyConfigUtility.ScreenState = System.Windows.Forms.FormWindowState.Maximized;
            else
                A1CompanyConfigUtility.ScreenState = System.Windows.Forms.FormWindowState.Normal;
            #endregion

            StrConfigValue = String.Empty;
            #region BoneModus
            StrConfigValue = A1CompanyConfigUtility.CompanyConfigFind("BoneModus", StrConfigValue);
            if (StrConfigValue == string.Empty)
                MessageBox.Show("#Message: BoneModus/EK - Please config company!");

            StrConfigValue = StrConfigValue.ToUpper();
            if (StrConfigValue.ToString()=="EK")
                A1CompanyConfigUtility.BoneModusEK = true;
            else
                A1CompanyConfigUtility.BoneModusEK = false;
            #endregion

        }

        static public String CompanyConfigFind(String Key, String Value)
        {
            String strFound;
            A1CompanyConfigUtility.CompanyConfig.TryGetValue(Key, out strFound);
            if (strFound != null)
                Value = strFound;
            return Value;
        }

 
    }
}



